package fr.fitec.qcmPlus.actionForms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class NouveauCompteForm extends ActionForm{
	

	private static final long serialVersionUID = 10L;
	
	private String nom				= 	null 	;
	private String prenom 			=	null	; 
	private String password			=	null	; 
	private String passwordconfirm	=	null	; 
	private String societe			=	null	;
	
	
	
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		
		this.nom				= 	null 	;
		this.prenom 			=	null	; 
		this.password			=	null	; 
		this.passwordconfirm	=	null	; 
		this.societe			=	null	;
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		
		ActionErrors errors = new ActionErrors();

        if ((this.nom == null) || (this.nom.length() < 4))
        	errors.add("nom", new ActionMessage("nouveaucompte.form.login.noncorrecte"));
        if ((password == null) || (password.length() < 4)){
        	errors.add("password", new ActionMessage("nouveaucompte.form.password.noncorrecte"));
        }	
        if ((prenom == null) || (prenom.length() < 2))
        	errors.add("prenom", new ActionMessage("nouveaucompte.form.prenom.noncorrecte"));
        if ((societe == null) || (societe.length() < 2))
        	errors.add("societe", new ActionMessage("nouveaucompte.form.societe.noncorrecte"));
        
        return errors;
	}
	
	public String getNom() {
		return nom;
	}
	
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPasswordconfirm() {
		return passwordconfirm;
	}
	public void setPasswordconfirm(String passwordconfirm) {
		this.passwordconfirm = passwordconfirm;
	}
	public String getSociete() {
		return societe;
	}
	public void setSociete(String societe) {
		this.societe = societe;
	}
	

	
	

}
